<template>
  <div>
    <!--引入 cateGorymenu 传参-->
    <cateGorymenu></cateGorymenu>
    <div class="region region--full">
      <comImg :imgData="imgData"></comImg>
    </div>
    <main id="maincontent" role="main">
      <div class="container container--zone removeLive" role="region">
        <!-- 引入公共组件 tabText.vue-->
        <!-- <tabText :listlinkData="listlinkData" :moreList="moreList" @tabChange="tabChange"></tabText> -->
        <div class="region region--primary">
          <!-- 引入公共组件面包屑  pageHead.vue-->
          <pageHead :titleData="titleData"></pageHead>
          <!-- 封装 引入 taxes 传参-->
          <nationNew :usNewsData="usNewsData"></nationNew>
          <!-- 日历组件 暂用 -->
          <div class="component component--module section-grid">
            <div class="column column--grid has-lead-image">
              <header class="header header--secondary">
                <a class="title" href="" target="_blank">
                  <div class="link">U.S. Economic Calendar</div>
                </a>
              </header>
              <div class="title__header link" style="width: 100%">
                <a href="" target="_blank">
                  <img
                    alt="Lead Image"
                    class="lazyloaded"
                    src="https://images.mktw.net/im-363899?size=custom_800x450"
                  />
                </a>
              </div>
            </div>
          </div>
          
        </div>
        <stickys :sticky="sticky"></stickys>
        <!-- 引入公共组件  marketPlace.vue  We Make-->
        <marketPlace></marketPlace>
        <!-- 引入 MOST POPULAR 组件 -->
      </div>

      <mastPopular></mastPopular>
      <div class="container container--zone" role="region">
        <div class="region region--primary">
          <!-- 小组件 暂用 未修改 -->
          <div class="component component--module text__block">
            <div class="column column--primary">
              <div class="element element--textblock">
                <h3>Bulletin alerts</h3>
                <p>
                  Get breaking news notifications via email. Straight from the
                  newsroom to your inbox.
                </p>
                <h4>
                  <a href="">Sign Up</a>
                </h4>
                <hr />
              </div>
            </div>
          </div>
          <!-- 封装 引入 taxes 传参-->
          <nationNew :usNewsData="usNewsData1"></nationNew>
          <!-- 封装 引入 taxes 传参-->
          <nationNew :usNewsData="usNewsData2"></nationNew>
          <!-- 封装 引入 movement 传参 需要修改-->

          <marketLine
            v-if="istext"
            :lastMarketData="lastMarketData"
          ></marketLine>
          <marketLine
            v-if="istext"
            :lastMarketData="lastMarketData1"
          ></marketLine>
        </div>
        <stickys :sticky="sticky"></stickys>
      </div>
    </main>
    <!-- 直接使用 未传参 -->
    <adverTisement></adverTisement>
  </div>
</template>
<script setup>
import cateGorymenu from "@/views/latestNews/cateGorymenu/cateGorymenu.vue"; //头部
import { newsDataArrays } from "@/api/economy.js";
// 引入面包屑模块
import pageHead from "@/components/pageHead/pageHead";
const titleData = reactive({
  title: "Latest News",
  link: "Home",
  name: "Latest News",
  name1: "",
});
// 引入公共组件  marketPlace.vue  We Make
import marketPlace from "@/views/latestNews/hotheHeadlines/marketPlace/marketPlace";
// 引入 MOST POPULAR 组件
import mastPopular from "@/views/home/mastPopular/mastPopular";
// 直接使用 未传参
import adverTisement from "@/views/home/adverTisement/adverTiseMent";
//
import nationNew from "@/views/market/nationNew/nationNew.vue";

import marketLine from "@/views/market/marketLine/marketLine.vue";
import comImg from "@/components/comImg/comImg.vue";
const imgData = ref("../src/assets/banner.png");
import stickys from "@/components/stickys/stickys.vue";
const sticky = ref("../src/assets/ceAdver.png");
// Categorymenu.vue  14行 下拉  21行 Asia
const isTextBc = ref(false);
const popularData = ref([]);
const { latestData, districtData, moreList } = newsDataArrays();
import homeRequest from "@/api/home.js";
import { onMounted } from "vue";
const listlinkData = ref([]);
let FrontData = ref([]);

let usNewsData = ref([]);
let usNewsData1 = ref([]);
let usNewsData2 = ref([]);

const isRegion = ref(false);
function frontData() {
  //新闻组
  let data = {
    key: "s",
  };
  homeRequest
    .getgroupData(data)
    .then((res) => {
      if (res.code == "0") {
        console.log(111);
        console.log(res);
        FrontData.value = res.data;
        if (FrontData.value.djn !== null) {
          usNewsData1.value = FrontData.value.djn;
          // timeNewsData.value = FrontData.value.auto;
          // popularData.value = FrontData.value.djn;
        }
        if (FrontData.value.cl !== null) {
          usNewsData.value = FrontData.value.cl;
        }
        if (FrontData.value.bs !== null) {
          usNewsData2.value = FrontData.value.bs;
        }
        isRegion.value = true;
      }
    })
    .catch((e) => {
      console.log("login error", e);
    });
}

let mdList = ref([]);
let lastMarketData = ref([]);
let lastMarketData1 = ref([]);
const istext = ref(false);
const getNewList = () => {
  let data = {
    current: 1,
    size: 50,
    isImg: 1,
    key: "stocks",
  };
  homeRequest
    .newsData(data)
    .then((res) => {
      if (res.code == "0") {
        console.log(res);
        mdList.value = res.data.records;
        if (mdList.value.length >= 6) {
          console.log(mdList.value);
          istext.value = true;
          lastMarketData.value = mdList.value.slice(0, 6);
        }
        if (mdList.value.length >= 12) {
          console.log(mdList.value);
          istext.value = true;
          lastMarketData1.value = mdList.value.slice(6, 12);
        }
      }
    })
    .catch((e) => {});
};
onMounted(() => {
  const data = localStorage.getItem("tabMdData");
  if (data) {
    listlinkData.value = JSON.parse(data).economy;
  }
  frontData();
  getNewList();
});
const tabChange = () => {};
</script>
<style lang="scss" scoped></style>
